package com.bookmarket.dao;


import com.bookmarket.entity.Book;
import com.bookmarket.entity.Btype;
import com.bookmarket.entity.Stype;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * LLBookDao
 *
 * @author 李亮
 * @date 2017/12/26
 */
@Repository("/bookdao")
public interface LLBookDao {
    public List<Book> getlist(Map<String, Object> cond);

    public Book getbook1(int id);

    @Select(" SELECT  count(1) from (tb_book A INNER JOIN tb_stype B ON A.stype_id = B.id) inner join tb_btype C on B.btype_id=C.btypeid where A.name like concat('%',#{name},'%')")
    public int getcount(Map<String, Object> cond);
    @Update("update tb_book set name=#{name},author=#{author},publish=#{publish},publish_date=#{publish_date},stock=#{stock},price=#{price},click=#{click},content=#{content} where id=#{id}")
    public boolean update(Book book);
    @Delete("delete  from tb_book  where id=#{id}")
    public boolean delet(int id);
    @Update("update tb_book set stype_id=#{stype.id} where id=#{id}")
    public void updat1(Book book);
    public Stype getstype1(int id);

    public List<Btype> getallbtype();
    public List<Stype> getastype(int id);
    List<Stype> getAllStype();
}